package com.youthburin.utils;

public/**
 * 请求：Range:(unit=first byte pos)-[last byte pos] <br>
 * 响应：Content-Range: bytes (unit first byte pos) - [last byte
 * pos]/[entitylegth]
 */
class FileDownLoadRange {
	private final int first;
	private final int last;
	private final int length;
	private final int totalLength;// 文件总长度

	public FileDownLoadRange(int first, int last, int totalLength) {
		this.first = first;
		this.totalLength = totalLength;

		this.last = last == 0 ? totalLength : last;

		this.length = this.last - this.first;
	}

	public int getFirst() {
		return first;
	}

	public int getLast() {
		return last;
	}

	public int getLength() {
		return length;
	}

	public int getTotalLength() {
		return totalLength;
	}

	public String getContentRange() {
		return String.format("bytes %d-%d/%d", this.first, this.last, this.length);
	}

}